<script setup>
import {reactive, ref} from "vue";
import {POST, PUT} from "../../../api/index.js";

const dialogFormVisible = ref(false)
const emit = defineEmits(['ok'])
const form = reactive({
  id: '',
  code: '',
  name: '',
  sort: 0
})

const open = (row) => {
  // form.id = row.id
  // form.upPrice = row.upPrice
  // form.downPrice = row.downPrice
  dialogFormVisible.value = true
}

const saveHandle = () => {
  POST('/futures/exchange', form).then(res => {
    dialogFormVisible.value = false
    emit('ok')
  })
}

defineExpose({
  open
})
</script>

<template>
  <el-dialog v-model="dialogFormVisible" title="编辑" width="500">
    <el-form :model="form">
      <el-form-item label="代码">
        <el-input v-model="form.code" autocomplete="off" />
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="form.name" autocomplete="off" />
      </el-form-item>
      <el-form-item label="排序">
        <el-input-number v-model="form.sort" :min="1" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="saveHandle">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>